<!--https://github.com/khan4019/tree-grid-directive-->
<h3 class="page-title">
    部门管理
    <small></small>
</h3>
<div class="table" ng-show="!edit">
    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                部门列表
                <button class="btn btn-success" ng-click="addRow()"><i class="fa fa-plus"></i> 新增</button>
                <button class="btn btn-default" onclick="$('#dept_table').treetable('expandAll');">全部展开</button>
                <button class="btn btn-default" onclick="$('#dept_table').treetable('collapseAll');">全部折叠</button>
            </div>
        </div>

        <div class="portlet-body">
            <table id="dept_table" class="table table-striped table-bordered table-advance table-hover">
                <thead>
                <tr>
                    <th>部门名称</th>
                    <th>部门简称</th>
                    <th>部门编码</th>
                    <th>部门类型</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="dept in depts" data-tt-id="{{dept.deptId}}" data-tt-parent-id='{{dept.parentDeptId}}'
                    on-finish-render-filters>
                    <td>{{dept.deptName}}</td>
                    <td>{{dept.shortName}}</td>
                    <td>{{dept.deptCode}}</td>
                    <td>{{dept.deptType | code : 'depttype'}}</td>
                    <td>
                        <button class="btn btn-xs btn-edit" ng-click="editDept(dept)"><i class="fa fa-edit"></i> 编辑
                        </button>
                        <button class="btn btn-xs btn-delete" ng-click="deleteDept(dept)"><i class="fa fa-trash-o"></i>
                            删除
                        </button>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="portlet light bordered edit" ng-show="edit">
    <div class="portlet-title">
        <div class="caption">
            <i class="icon-equalizer font-red-sunglo"></i>
            <span class="caption-subject font-red-sunglo bold uppercase">部门编辑</span>
        </div>
        <div class="actions">
            <a class="btn btn-circle btn-icon-only btn-default" href="javascript:;" ng-click="cancel();">
                <i class="icon-action-undo"></i>
            </a>
        </div>
    </div>

    <div class="portlet-body form">
        <!-- BEGIN FORM-->
        <form action="#" class="form-horizontal w5c-form" w5c-form-validate novalidate name="validateForm">

            <div class="form-body">
                <div class="form-group">
                    <label class="col-md-3 control-label">上级部门</label>

                    <div class="col-md-4">
                        <div ed-combotree data-options="idField: 'deptId', textField: 'deptName', parentIdField: 'parentDeptId'"
                             ng-model="dept.parentDeptId" ed-data="depts" placeholder="请选择上级部门" ng-show="!dept.parentDeptName" name="parentDeptName" required></div>
                        <input type="text" class="form-control" ng-model="dept.parentDeptName" ng-show="dept.parentDeptName" readonly>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-3 control-label">部门名称</label>

                    <div class="col-md-4">
                        <input type="text" class="form-control" ng-model="dept.deptName" name="deptName" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">部门简称</label>

                    <div class="col-md-4">
                        <input type="text" class="form-control" ng-model="dept.shortName" name="shortName" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">部门编码</label>

                    <div class="col-md-4">
                        <input type="text" class="form-control" ng-model="dept.deptCode" name="deptCode" required>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">部门类型</label>

                    <div class="col-md-4">
                        <select class="form-control" ng-model="dept.deptType"
                                ng-options="opt.value as opt.name for opt in options.depttype"></select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-3 control-label">部门简介</label>

                    <div class="col-md-4">
                        <textarea class="form-control" rows="3" ng-model="dept.remark" name="remark"></textarea>
                    </div>
                </div>
            </div>
            <div class="form-actions">
                <div class="row">
                    <div class="col-md-offset-3 col-md-4">
                        <button type="button" class="btn green" w5c-form-submit="save()"><i class="fa fa-save"></i> 保存
                        </button>
                        <button type="button" class="btn default" ng-click="cancel();validateForm.reset();"><i
                                class="fa fa-times"></i> 取消
                        </button>
                    </div>
                </div>
            </div>
        </form>
        <!-- END FORM-->
    </div>
</div>